﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace GameFramework
{
    public class GameFrameworkLinkedListNode<T> : AbstractReference
    {
        internal GameFrameworkLinkedList<T> list;
        internal GameFrameworkLinkedListNode<T> next;
        internal GameFrameworkLinkedListNode<T> prev;
        internal T item;
        public GameFrameworkLinkedListNode()
        { 
        }
        public GameFrameworkLinkedListNode(T v)
        {
            item = v;
        }

        public GameFrameworkLinkedList<T> List { get { return list; } }
        public GameFrameworkLinkedListNode<T> Next
        {
            get { return next == null || next == list.head ? null : next; }
        }
        public GameFrameworkLinkedListNode<T> Previous
        {
            get { return prev == null || this == list.head ? null : prev; }
        }
        public T Value { get { return item; } set { item = value; } }
        public override void Clear()
        {
            list = null;
            next = null;
            prev = null;
            item = default;
        }
    }
}